package com.cn.dao;

import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.cn.domain.Book;

public class BookDao extends HibernateDaoSupport{

	public List<Book> findAllBook() {
	    String hql="from Book order by pressdate DESC";
	    List<Book> listbooks = this.getHibernateTemplate().find(hql);
	    if(listbooks!=null&&listbooks.size()>0)
	    return listbooks;
	    return null;
	}

	public Book getBookId(int bid) {
	    Book book = (Book)this.getHibernateTemplate().get(Book.class, bid);
	    if(book!=null)  
	    return book;
		return null;
	}

	public void deleteBook(Book book) {
		
		this.getHibernateTemplate().delete(book);
		
	}

	public void saveBook(Book model) {
		
		this.getHibernateTemplate().save(model);
	}

	public void updateBook(Book book) {
		
		this.getHibernateTemplate().update(book);
		
	}

}
